package org.example.Event;

import org.example.Event.listener.BaseListener;

import java.util.EventObject;
import java.util.HashSet;
import java.util.Iterator;

public class EventManager {
    protected static HashSet<BaseListener> listeners = new HashSet<>();

    public static void addListener(BaseListener eventListener){
        listeners.add(eventListener);
    }

    public static void removeListener(BaseListener eventListener){
        listeners.remove(eventListener);
    }

    public static void informListeners(EventObject e){
        Iterator<BaseListener> it = listeners.iterator();
        while(it.hasNext()){
            it.next().respond(e);
        }
    }
}
